﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace KY_ExcelAddIn
{
    public partial class ProcessStatus : Form
    {
        public ProcessStatus()
        {
            InitializeComponent();
            this.Show();
            backgroundWorker.RunWorkerAsync();
        }

        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            
            for (int i = 1; i <= 100; i++)
            {
                Thread.Sleep(50);
                backgroundWorker.ReportProgress(i);
            }
            
        }

        private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {

            label1.Text = string.Format("Processing... {0}% complete", e.ProgressPercentage);
            progressBar.Value = e.ProgressPercentage;
        }

        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            label1.Text = "Processing... 100% complete";
            progressBar.Value = 100;
            Thread.Sleep(5000);
            //this.Close();
        }
    }
}
